package com.jspgou.cms.action.store;

import static com.jspgou.cms.Constants.STORE_SYS;
import static com.jspgou.common.page.SimplePage.cpn;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jspgou.cms.entity.ShopMember;
import com.jspgou.cms.entity.Store;
import com.jspgou.cms.manager.BalanceMng;
import com.jspgou.cms.web.CmsUtils;
import com.jspgou.cms.web.ShopFrontHelper;
import com.jspgou.cms.web.SiteUtils;
import com.jspgou.common.page.Pagination;
import com.jspgou.common.web.CookieUtils;
import com.jspgou.common.web.springmvc.MessageResolver;
import com.jspgou.core.entity.Website;

@Controller
public class BalanceFroAct {
	/**
	 * 店铺售后详情页
	 */
	private static final String TPL_BALANCE_LIST="tpl.balanceList";
	@RequestMapping("/balanceFro/list.jspx")
	public String list(String cl,Date startTime,Date endTime,Integer pageNo,
			HttpServletRequest request, ModelMap model) {
		Website web = SiteUtils.getWeb(request);
		ShopMember member=CmsUtils.getMember(request);
		//用户没有登录，跳转到登录页
		if(member == null){
			return ShopFrontHelper.showLogin(request, model, web);
		}
		Store store=member.getStore();
		Pagination pagination =manager.getPage(null,null, startTime, endTime, cpn(pageNo), CookieUtils
				.getPageSize(request));
		model.addAttribute("pagination",pagination);
		model.addAttribute("pageNo",pageNo);
		model.addAttribute("store",store);
		model.addAttribute("cl", cl);
		ShopFrontHelper.setCommonData(request, model, web);
		ShopFrontHelper.frontPageData(request, model);
		return web.getTplSys(STORE_SYS, MessageResolver.getMessage(request,TPL_BALANCE_LIST), request);
	}
	
	@Autowired
	private BalanceMng manager;
}
